<?php
namespace Common\Model;

use Think\Model;
use Closure;
/**
 */
class WechatModel extends Model{
    public function info($query = null, $field = true, Closure $closure = null){
        $map = array();

        // 判断查询单条数据还是多条数据
        isset($query['id']) && $query['id']>0 && $map['id'] = $query['id'];
        unset($query['id']);
        foreach($query as $k=>$v){
            $map[$k] = $v;
        }

        $res = $this
            ->where($map)
            ->field($field)
            ->find();
        if ( $closure ) {
            $res = $closure($res);
        }

        return $res;
    }
}
